﻿using System.Collections;
using Inkubator.Wizard.Model.Model;
using System.Web.UI.WebControls;

namespace Inkubator.Wizard.WizardGenerator.Generator
{
    public class CreateControl
    {
        private Hashtable tableModel;

        public CreateControl()
        {
            tableModel = new Hashtable();
            tableModel.Add(typeof(Text).ToString(), WebControlFactory.ControlType.Text );
            tableModel.Add( typeof(Group).ToString(), WebControlFactory.ControlType.Group );
            tableModel.Add(typeof(Date).ToString(), WebControlFactory.ControlType.Date );
            tableModel.Add(typeof(TableData).ToString(), WebControlFactory.ControlType.Table );
        }

        /// <summary>
        /// This method return a WebControl.
        /// </summary>
        /// <param name="component"></param>
        /// <returns></returns>
        public WebControl obtainControl(WizardComponent component)
        {
            WebControl control;

            control = WebControlFactory.webControlFactory( 
                ((WebControlFactory.ControlType) tableModel[component.GetType().ToString()]), component );

            return control;
        }

    }
}
